package main

import (
	"fmt"
)

func GetNameAndAge() (string, int) {
	return "Tom", 20
}

func main() {
	/* 变量声明 （声明后必须使用。赋新值不算使用，变量的值赋值给其他变量算使用）*/
	var name string = "main"

	s := name
	fmt.Printf("s: %v\n", s)
	/* 变量使用 */
	// fmt.Printf("name: %v\n", name)

	/* 变量批量声明 */
	var (
		age int
		b   bool
	)

	b = true
	age = 18

	fmt.Printf("age: %v\n", age)
	fmt.Printf("b: %v\n", b)

	/* 变量初始化 即声明时赋初值 */
	var (
		ip string = "192.168.1.1"
	)

	var site string = "www.baidu.com"
	fmt.Printf("ip: %v\n", ip)
	fmt.Printf("site: %v\n", site)

	/* 类型推断 */
	var id = 3
	var nick_name = "Bob"
	fmt.Printf("id: %v\n", id)
	fmt.Printf("nick_name: %v\n", nick_name)

	/* 批量初始化 */
	var pet_name, pet_age, pet_sex = "Wangwang", 3, "Male"
	fmt.Printf("pet_age: %v\n", pet_age)
	fmt.Printf("pet_name: %v\n", pet_name)
	fmt.Printf("pet_sex: %v\n", pet_sex)

	/* 短变量声明 */
	friend_name := "Brown"
	fmt.Printf("friend_name: %v\n", friend_name)

	/* 匿名变量 */
	_, friend_age := GetNameAndAge()
	fmt.Printf("friend_age: %v\n", friend_age)

}
